home *** CD-ROM | disk | FTP | other *** search
- // BD - 3/4/92 - added init of oldState
-
- integer oldState;
-
- on initsim
- {
- oldState = FALSE;
- }
-
- on createBlock
- {
- hysteresis = 0.0;
- oldstate = FALSE;
- }
-
- on simulate
- {
- if (oldState)
- {
- if (con2in > con1in+hysteresis)
- oldState = FALSE;
- }
- else
- {
- if (con1in > con2in+hysteresis)
- oldState = TRUE;
- }
-
- if (inverting)
- con3out = !oldState;
- else
- con3Out = oldState;
-
- ** sysGlobal2 is the file reference number for the DEBUG TRACE
- if( sysGlobal2 != 0.0 ) ** 0 is error, check for open file for TRACE
- {
- // template for report: |BLOCK NAME *****************|block number |BLOCK NUMBER*******
- fileWrite(sysGlobal2,"Comparator block number "+(MyBlockNumber())+". Current Time:"+currentTime+".","",True);
- if(getBlockLabel(myBlockNumber()) != "")
- fileWrite(sysGlobal2,"Block Label: "+getBlockLabel(myBlockNumber()),"",True);
- fileWrite(sysGlobal2," Input+ = "+con1In,"",True);
- fileWrite(sysGlobal2," Input- = "+con2In,"",True);
- fileWrite(sysGlobal2," Output = "+con3out,"",True);
- fileWrite(sysGlobal2," ","",True);
- }
- }
-
- on endSim
- {
- ** sysGlobal1 is the file reference number for the TEXT REPORT
- if( sysGlobal1 != 0.0 ) ** 0 is error, check for open file for REPORT
- {
- // template for report: |BLOCK NAME *****************|block number |BLOCK NUMBER*******
- fileWrite(sysGlobal1,"Comparator block number "+(MyBlockNumber()),"",True);
- if(getBlockLabel(myBlockNumber()) != "")
- fileWrite(sysGlobal1,"Block Label: "+getBlockLabel(myBlockNumber()),"",True);
- fileWrite(sysGlobal1," Hysteresis = "+hysteresis,"",True);
- If (inverting)
- fileWrite(sysGlobal1," Inverting mode","",True);
- else
- fileWrite(sysGlobal1," Non-inverting mode","",True);
- if( comments != "" )
- fileWrite(sysGlobal1," Comments = "+comments,"",True);
- fileWrite(sysGlobal1," ","",True);
- }
- }
-